package com.hellogood.yaohuo.server.serviceImpl;

import java.util.LinkedHashMap;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.hellogood.yaohuo.server.mgr.factory.MgrFactory;
import com.hellogood.yaohuo.shared.entity.Org;
import com.hellogood.yaohuo.shared.services.OrgService;

public class OrgServiceImpl extends RemoteServiceServlet implements OrgService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8099244882038448387L;

	@Override
	public List<Org> getAllOrgList() {
		return MgrFactory.getInstance().createOrgMgr().getOrgList();
	}

	@Override
	public List<Org> getUnQuyuedOrgList() {
		return MgrFactory.getInstance().createOrgMgr().getUnQuyuedOrgList();
	}

	@Override
	public List<Org> getOrgListByQuyuCode(String quyuCode) {
		return MgrFactory.getInstance().createOrgMgr().getOrgListByQuyuCode(quyuCode);
	}

	@Override
	public List<Org> getOrgListByStaffCode(String staffCode) {
		return MgrFactory.getInstance().createOrgMgr().getOrgListByUserCode(staffCode);
	}

	@Override
	public Org getOrgByCode(String orgCode) {
		return MgrFactory.getInstance().createOrgMgr().getCOrgByCode(orgCode);
	}

	@Override
	public Org getOrgByCodeStaffCode(String orgCode, String staffCode) {
		return MgrFactory.getInstance().createOrgMgr().getOrgByCodeStaffCode(orgCode, staffCode);
	}

	@Override
	public LinkedHashMap<String, String> getOrgMapByStaffCode(String staffCode) {
		LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
		map.put("0", "全部");
		List<Org> orgList = MgrFactory.getInstance().createOrgMgr().getOrgListByUserCode(staffCode);
		if (orgList != null) {
			for (Org o : orgList) {
				map.put(o.getOrgCode(), o.getOrgCode() + "-" + o.getOrgName());
			}
		}
		return map;
	}

	@Override
	public List<Org> getCOrgListByStaffCode() {
		return MgrFactory.getInstance().createOrgMgr().getCOrgList();
	}

	@Override
	public Org getCOrgByCode(String orgCode) {
		return MgrFactory.getInstance().createOrgMgr().getCOrgByCode(orgCode);
	}

}
